﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DLMemberPointMS.Entity.POCOModel;
using DLMemberPointMS.Entity.ViewModel;
using DLMemberPointMS.Common;

namespace DLMemberPointMS.Business
{
    public class CountGirfSerives : BaseService<ExchangLogs>
    {

        /// <summary>
        /// 分页礼品兑换
        /// </summary>
        /// <param name="viewModel"></param>
        /// <returns></returns>
        public OperateResult GetCardlevels(GirfCountView viewModel)
        {
            var query = PredicateExtensions.True<ExchangLogs>();
            if (!string.IsNullOrEmpty(viewModel.MC_CardID))
            {
                query = query.And(e => e.MC_CardID.Contains(viewModel.MC_CardID));
            }

            int rowCount = 0;//总条数
            var pageData = GetList(viewModel.page, viewModel.limit, ref rowCount, query, e => e.EL_ID, true).Select(
                e => new
                {
                    e.MC_CardID,
                    e.EG_GiftName,
                    e.MC_Name,
                    e.EG_ID,
                    e.EL_Point,
                    e.EL_Number,
                    e.EL_CreateTime

                }).ToList();
            return new OperateResult(code.Success, "", pageData, rowCount);
        }
    }
}
